package com.ez2find.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;

@NamedQueries(value = {@NamedQuery(name = "selectMessages", query = "SELECT c FROM Message c"),
    @NamedQuery(name = "messagesTopic", query = "SELECT a FROM Message a WHERE a.topic=:topic"),
    @NamedQuery(name = "messagesMessage", query = "SELECT a FROM Message a WHERE a.message=:message")
})
@Entity
public class Message implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date creationDate;
    private String subject;
    private String content;
    private String type;
    private int level;
    @ManyToOne
    private Nick handle;
    @ManyToOne
    private Topic topic;
    @ManyToOne
    private RegisterUser user;
    @ManyToOne
    private Message message;
    @OneToMany(mappedBy = "message", cascade = CascadeType.PERSIST)
    private List<Message> messages;
    @OneToMany(mappedBy = "message", cascade = CascadeType.REMOVE)
    private List<Flag> flags;

    public void setId(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public Date getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(Date creationDate) {
        this.creationDate = creationDate;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Topic getTopic() {
        return topic;
    }

    public void setTopic(Topic topic) {
        this.topic = topic;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public RegisterUser getUser() {
        return user;
    }

    public void setUser(RegisterUser user) {
        this.user = user;
    }

    public Message getMessage() {
        return message;
    }

    public void setMessage(Message message) {
        this.message = message;
    }

    public List<Message> getMessages() {
        if (messages == null) {
            messages = new ArrayList<Message>();
        }
        return messages;
    }

    public void setMessages(List<Message> messages) {
        this.messages = messages;
    }

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    public Nick getHandle() {
        return handle;
    }

    public void setHandle(Nick handle) {
        this.handle = handle;
    }

    public List<Flag> getFlags() {
        if (flags == null) {
            flags = new ArrayList<Flag>();
        }
        return flags;
    }

    public void setFlags(List<Flag> flags) {
        this.flags = flags;
    }

    public List<Flag> getCarajazos() {
        if (flags == null) {
            flags = new ArrayList<Flag>();
        }
        return flags;
    }

    public List<Flag> getPuteadas() {
        if (flags == null) {
            flags = new ArrayList<Flag>();
        }
        return flags;
    }

    public List<Flag> getBanderas1() {
        if (flags == null) {
            flags = new ArrayList<Flag>();
        }
        return flags;
    }

    public List<Flag> getMierdazos() {
        if (flags == null) {
            flags = new ArrayList<Flag>();
        }
        return flags;
    }

    public List<Flag> getMierdeadas() {
        if (flags == null) {
            flags = new ArrayList<Flag>();
        }
        return flags;
    }

    public List<Flag> getBanderitas() {
        if (flags == null) {
            flags = new ArrayList<Flag>();
        }
        return flags;
    }
    
    public List<Flag> getBanderotas(){
        if (flags == null) {
            flags = new ArrayList<Flag>();
        }
        return flags;
    }
}
